package com.ruoyi.system.controller;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.SupplierMaterial;
import com.ruoyi.system.service.ISupplierMaterialService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 供应商物料库存Controller
 *
 * @author 协同
 * @date 2022-04-18
 */
@RestController
@RequestMapping("/system/supplierMaterial")
public class SupplierMaterialController extends BaseController {
    @Resource
    private ISupplierMaterialService supplierMaterialService;

    /**
     * 查询供应商物料库存列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SupplierMaterial supplierMaterial) {
        startPage();
        List<SupplierMaterial> list = supplierMaterialService.selectSupplierMaterialList(supplierMaterial);
        return getDataTable(list);
    }

    /**
     * 获取供应商物料库存详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(supplierMaterialService.selectSupplierMaterialById(id));
    }

    /**
     * 新增供应商物料库存
     */
    @PostMapping
    public AjaxResult add(@RequestBody SupplierMaterial supplierMaterial) {
        return toAjax(supplierMaterialService.insertSupplierMaterial(supplierMaterial));
    }

    /**
     * 修改供应商物料库存
     */
    @PutMapping
    public AjaxResult edit(@RequestBody SupplierMaterial supplierMaterial) {
        return toAjax(supplierMaterialService.updateSupplierMaterial(supplierMaterial));
    }

    /**
     * 删除供应商物料库存
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(supplierMaterialService.deleteSupplierMaterialByIds(ids));
    }
}
